package top.shen33.yang.services.impl;



import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import top.shen33.yang.model.entity.QrtzJobDetails;
import top.shen33.yang.mapper.QrtzJobDetailsMapper;
import top.shen33.yang.model.vo.QuartzEntity;
import top.shen33.yang.services.QrtzJobDetailsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author oreilly
 * @since 2018-09-06
 */
@Service
public class QrtzJobDetailsServiceImpl extends ServiceImpl<QrtzJobDetailsMapper, QrtzJobDetails>implements QrtzJobDetailsService {


    @Override
    public Class clazz() {
        return QrtzJobDetails.class;
    }

    @Override
    public void doAdd(QrtzJobDetails itemQrtzJobDetails) {

        itemQrtzJobDetails.insertOrUpdate();
    }

    @Override
    public void doUpdate(QrtzJobDetails itemQrtzJobDetails) {

        itemQrtzJobDetails.insertOrUpdate();
    }

    @Override
    public void doDelete(String[] ids) {

        QueryWrapper<QrtzJobDetails> ew = new QueryWrapper<>();
        ew.in("sid", ids);
        new QrtzJobDetails().delete(ew);
    }

    @Override
    public QrtzJobDetails getOne(String sid) {

        //关联查询

        QrtzJobDetails itemQrtzJobDetails = getById(sid);

        return itemQrtzJobDetails;
    }

    @Override
    public List<QrtzJobDetails> all(QrtzJobDetails itemQrtzJobDetails) {

        return this.baseMapper.all(itemQrtzJobDetails);
    }


        @Override
    public Page<QrtzJobDetails> pageInfo(Page page, QrtzJobDetails itemQrtzJobDetails) {

        List<QrtzJobDetails> dataList = this.baseMapper.pageInfo(page, itemQrtzJobDetails);
        if(page ==null ){
            page = new Page(0,10000);
        }
        page.setRecords(dataList);
        return page;
    }


    @Override
    public void doImport(List<QrtzJobDetails> dataList) {

        //数据验证

        //保存
        this.saveOrUpdateBatch(dataList);
    }

    @Override
    public List<QuartzEntity> listQuartzEntity(QuartzEntity quartz, Page page) {
        return baseMapper.listQuartzEntity(quartz,page);
    }

    @Override
    public QuartzEntity getOneQuartzEntity(Serializable sid) {
        return baseMapper.getOneQuartzEntity(sid);
    }

    @Override
    public Integer total(QuartzEntity quartz) {
        return baseMapper.total( quartz);
    }
}
